﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class admin_user : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (Session["login"] == null)
            {
                Response.Redirect("login.aspx");
            }
            else
            {
                rptdatabind();
            }
        }
        
    }

    private void rptdatabind()
    {
        YqhData obj = new YqhData();
        Repeater1.DataSource = obj.FillDataSet("select uid,uname,upwd,upower=Case upower when 0 then '普通用户' when 1 then '管理员'End from userinfo");
        Repeater1.DataBind();
    }
    protected void Repeater1_ItemCommand(object source, RepeaterCommandEventArgs e)
    {
        YqhData obj = new YqhData();
        switch (e.CommandName.ToLower())
        {
            case "del":
                string sql = string.Format("delete userinfo where uid={0}", e.CommandArgument);
                obj.ExecuteSql(sql);
                rptdatabind();
                break;
            case "e":
                Response.Redirect(string.Format("useredit.aspx?op=e&id={0}", e.CommandArgument));
                break;
        }
    }
}